package com.eddie.principle.singleresponsibility;

import lombok.extern.slf4j.Slf4j;

/**
 * @author Eddie
 * @date 2022/4/27 12:39
 */
public class SingleResponsibility2 {

    public static void main(String[] args) {
        RoadVehicle roadVehicle = new RoadVehicle();
        roadVehicle.run("摩托车");
        roadVehicle.run("汽车");
        AirVehicle airVehicle = new AirVehicle();
        airVehicle.run("飞机");
    }

}


/**
 * 方案2的分析：
 *  1、遵守了单一职责原则
 *  2、但是这样做的改动很大，既要将这个类分解，同时修改客户端
 *  3、改进：直接修改Vehicle类，改动的代码会比较少=>方案3
 */
@Slf4j
class RoadVehicle {
    public void run(String vehicle) {
        log.info(vehicle + "在公路运行");
    }
}
@Slf4j
class AirVehicle {
    public void run(String vehicle) {
        log.info(vehicle + "在天空运行");
    }
}
@Slf4j
class WaterVehicle {
    public void run(String vehicle) {
        log.info(vehicle + "在水中运行");
    }
}